<template>
  <div class="main_spac1">
    <div class="main_white padding10">
      <div class="mainor_form">
        <div class="mainor_te mainsa_te">
          <el-checkbox v-model="type" @change="checkbox"
            >不打印标签</el-checkbox
          >
          <el-tooltip
            class="item marginLeft5"
            effect="dark"
            content="此功能只会影响在分拣时是否打印标签"
            placement="bottom-end"
          >
            <svg aria-hidden="true" class="navbar_svg" width="14" height="14">
              <use xlink:href="#icon-summary_question" />
            </svg>
          </el-tooltip>
        </div>
        <div class="mainor_te on">
          <el-button v-repeatClick>一键打印</el-button>
          <el-button v-repeatClick>批量打印拣货单</el-button>
          <el-button @click="dialogFormVisible = true">表头设置</el-button>
          <el-button v-repeatClick>打印所有拣货单</el-button>
        </div>

        <el-form
          :inline="true"
          :model="form"
          class="demo-form-inline"
          ref="userListFrom"
          label-width="80px"
        >
          <el-form-item label="配送日期" prop="send_time">
            <el-date-picker
              v-model="form.send_time"
              type="date"
              class="wid220"
              :editable="false"
              placeholder="选择配送日期"
              value-format="yyyy-MM-dd"
              :clearable="false"
            />
          </el-form-item>
          <el-form-item label="商户名称" prop="select">
            <el-input
              v-model.trim="form.company_name"
              placeholder="商户名称"
              clearable
              class="wid220"
            ></el-input>
          </el-form-item>
          <el-form-item label="配送时间">
            <el-select
              v-model.trim="form.send_time_id"
              placeholder="配送时间"
              class="wid220"
            >
              <el-option label="所有" :value="parseInt(0)"></el-option>
              <el-option
                v-for="(send_time_list, index) in list.send_time_list"
                :key="index"
                :label="send_time_list"
                :value="index"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="分拣状态">
            <el-select
              v-model.trim="form.sorting"
              placeholder="分拣状态"
              class="wid220"
            >
              <el-option label="所有" :value="parseInt(0)"></el-option>
              <el-option
                v-for="(send_time_list, index) in list.is_standardList"
                :key="index"
                :label="send_time_list"
                :value="parseInt(index + 1)"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-button
              class="reset marginLeft10"
              type="primary"
              @click="
                $refs['userListFrom'].resetFields(),
                  (createTime = []),
                  (establishTime = [])
              "
              >重置</el-button
            >
            <el-button
              type="primary"
              @click="getArticleList"
              :loading="listLoading"
              >搜索</el-button
            >
          </el-form-item>
        </el-form>
      </div>

      <div class="main_num boxdq">
        <!-- 分拣报表 -->
        <div class="main_num_l box">
          <p>
            总分拣订单：
            <em>{{ sort_arr_list.count || 0 }}</em>
          </p>
          <p>
            已分拣完成订单：
            <em>{{ over_count || 0 }}</em>
          </p>
          <p>
            未分拣订单：
            <em>{{ sort_arr_list.up_count || 0 }}</em>
          </p>
          <p>
            部分分拣订单：
            <em>{{ sort_arr_list.in_count || 0 }}</em>
          </p>
          <p class="box" style="width: 400px; align-items: center">
            分拣进度：
            <el-progress
              :text-inside="true"
              :stroke-width="15"
              :percentage="fenjian_percent"
              status="success"
              color="#E47C02"
              style="width: 60%"
            ></el-progress>
          </p>
        </div>
        <div class="mainsu_te" style="position: relative">
          <el-checkbox-group v-model="checkList">
            <div class="mainsw_tax_t">
              <el-button type="primary" v-repeatClick>打印拣货单</el-button>
            </div>
          </el-checkbox-group>
        </div>
      </div>
      <div class="mainsw_tax">
        <div class="main_table">
          <el-table
            ref="multipleTable"
            element-loading-text="加载中"
            v-loading="listLoading"
            :data="list.list"
            fit
            border
          >
            <el-table-column type="expand">
              <template slot-scope="props">
                <el-table
                  :data="props.row.list"
                  fit
                  border
                  highlight-current-row
                  class="main_table"
                  @current-change="demo"
                >
                  <el-table-column fixed label="序号" width="80">
                    <template slot-scope="props">{{
                      props.$index + 1
                    }}</template>
                  </el-table-column>
                  <div v-for="(field, index) in field" :key="index">
                    <el-table-column
                      label="商品名称"
                      width="120"
                      prop="name"
                      v-if="field == 1"
                    />
                    <el-table-column
                      label="下单数量"
                      width="120"
                      prop="order_num"
                      :show-overflow-tooltip="true"
                      v-if="field == 2"
                    />
                    <el-table-column
                      label="分拣数量"
                      width="150"
                      v-if="field == 3"
                    >
                      <template slot-scope="scope">
                        <el-input
                          :ref="'sorting' + props.$index + scope.$index"
                          v-model="scope.row.sort_num"
                          :disabled="scope.row.disabled"
                          placeholder="分拣数量"
                          class="wid80"
                          size="mini"
                          @focus="
                            inputFocus(
                              [props.$index, scope.$index],
                              scope,
                              $event
                            )
                          "
                          @keyup.enter.native="nextFocus(props, scope, $event)"
                        ></el-input>
                        <!-- @change="
                            (val) => {
                              fenjiancount(val, scope);
                            }
                          " -->
                      </template>
                    </el-table-column>
                    <el-table-column
                      label="分拣单位"
                      width="120"
                      v-if="field == 4"
                    >
                      <template slot-scope="props">
                        {{
                          props.row.transfer_unit
                            ? props.row.transfer_unit
                            : props.row.unit
                        }}
                      </template>
                    </el-table-column>
                    <el-table-column
                      label="生产日期"
                      width="150"
                      v-if="field == 5"
                    >
                      <template slot-scope="props">
                        <el-date-picker
                          v-model="props.row.mfg"
                          type="date"
                          class="wid120"
                          :editable="false"
                          placeholder="生产日期"
                          value-format="yyyy-MM-dd"
                          :clearable="false"
                          :disabled="props.row.disabled"
                          size="mini"
                          @change="
                            (val) => {
                              fenjiantime(val, props);
                            }
                          "
                        />
                      </template>
                    </el-table-column>
                    <el-table-column label="库存" width="120" v-if="field == 6">
                      <template slot-scope="props">{{
                        props.row.storehouse_inventory
                          ? props.row.storehouse_inventory
                          : 0
                      }}</template>
                    </el-table-column>
                    <el-table-column
                      label="库存均价"
                      prop="inventory_price"
                      width="120"
                      v-if="field == 7"
                    />
                    <el-table-column
                      label="分拣状态"
                      width="100"
                      v-if="field == 8"
                    >
                      <template slot-scope="props">
                        <div class="main_link">
                          <el-link type="danger" v-if="props.row.status == 0"
                            >未分拣</el-link
                          >
                          <el-link type="success" v-else>已分拣</el-link>
                        </div>
                      </template>
                    </el-table-column>
                    <el-table-column
                      label="备注"
                      width="120"
                      prop="remark"
                      v-if="field == 9"
                    />
                    <el-table-column
                      label="分拣员"
                      width="100"
                      prop="users"
                      v-if="field == 10"
                    />
                    <el-table-column
                      label="分拣时间"
                      width="120"
                      v-if="field == 11"
                    >
                      <template slot-scope="props">
                        {{
                          props.row.sort_time
                            ? parseTime(props.row.sort_time, "{y}-{m}-{d}")
                            : ""
                        }}
                      </template>
                    </el-table-column>
                  </div>
                  <el-table-column
                    label="管理操作"
                    align="center"
                    fixed="right"
                    width="250"
                    class-name="main_hei"
                  >
                    <template slot-scope="props">
                      <el-link @click="qrAccount">打印</el-link>
                      <el-popconfirm
                        title="您确定对该商品进行缺货备注吗？"
                        @onConfirm="quehuo(props.row.id)"
                      >
                        <el-link type="success" v-if="props.row.status == 0"
                          >缺货</el-link
                        >
                      </el-popconfirm>
                      <el-link
                        type="primary"
                        v-if="props.row.status == 1"
                        @click="xiugaiMethod(props)"
                        slot="reference"
                        >修改</el-link
                      >
                      <el-link
                        @click="accumu(props)"
                        v-if="props.row.status == 1"
                        >累加</el-link
                      >
                      <el-popconfirm
                        title="您确定对该商品进行撤销吗"
                        @onConfirm="chexiao(props.row.id)"
                      >
                        <el-link
                          type="danger"
                          slot="reference"
                          v-if="props.row.status == 1"
                          >撤销</el-link
                        >
                      </el-popconfirm>
                    </template>
                  </el-table-column>
                </el-table>
              </template>
            </el-table-column>
            <el-table-column label="序号">
              <template slot-scope="scope">{{ scope.$index + 1 }}</template>
            </el-table-column>
            <el-table-column
              label="商户名"
              :show-overflow-tooltip="true"
              prop="company_name"
            >
            </el-table-column>
            <el-table-column
              label="收货人"
              :show-overflow-tooltip="true"
              prop="receive_man"
            />
            <el-table-column
              label="收货手机"
              :show-overflow-tooltip="true"
              prop="receive_mobile"
            />
            <el-table-column
              label="收货地址"
              :show-overflow-tooltip="true"
              prop="receive_address"
            />
          </el-table>
        </div>
      </div>

      <div class="main_page boxdq">
        <div></div>
        <!-- 分页 -->
        <div class="main_page_r">
          <el-pagination
            :current-page="current.page"
            :page-sizes="[20, 30, 50, 100]"
            :page-size="limit"
            layout="total, sizes, prev, pager, next, jumper"
            :total="totalCount"
            background
            @size-change="changeLimit"
            @current-change="changePage"
          />
        </div>
      </div>
    </div>

    <el-dialog
      title="表头设置"
      :visible.sync="dialogFormVisible"
      class="main_dialog dialog500"
      @close="type = list.field"
    >
      <el-checkbox-group v-model="type">
        <el-checkbox
          v-for="(Header, index) in Header"
          :key="index"
          :label="Header.id"
          :disabled="Header.disabled"
          >{{ Header.name }}</el-checkbox
        >
      </el-checkbox-group>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="setupmine" v-repeatClick
          >确 定</el-button
        >
      </div>
    </el-dialog>

    <!-- 累加分拣弹出窗 -->
    <el-dialog
      title="累加分拣"
      :visible.sync="addDialogFormVisible"
      width="30%"
    >
      <el-form :model="form">
        <el-form-item label="分拣数量" label-width="100px" class="addfenjian">
          <el-input
            v-model="addInfo.new_num"
            autocomplete="off"
            placeholder="智能称或输入数量后回车"
            size="medium"
            autofocus="true"
            type="number"
            @change="countadd(1)"
          ></el-input>
        </el-form-item>
        <el-form-item label="是否分次打印" label-width="100px">
          <el-tooltip
            class="item"
            effect="dark"
            content="勾选后，每次累加数量都会打印标签"
            placement="top"
          >
            <i class="el-icon-question icon" style="padding-rigth: 30px"></i>
          </el-tooltip>
          <el-switch
            v-model="isPrint"
            active-text="开"
            inactive-text="关"
            active-color="#03A98E"
            class="mainor_switch"
            style="margin-left: 20px"
          ></el-switch>
        </el-form-item>
        <el-form-item label="分拣数量" label-width="100px">
          <el-tag
            size="mini"
            v-for="(item, index) in addInfo.numhistory"
            style="margin-right: 8px"
            :key="index"
            >{{ item }}</el-tag
          >
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="accountComplete">完 成</el-button>
        <el-button type="primary" @click="qrAccount">打 印</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { getLodop } from "@/utils/LodopFuncs";
import {
  sorting_text,
  sorting_accumulation,
  sorting_stock,
  sorting_revoke,
  sorting_add,
} from "@/api/sorting/sortingStart";
import { apiUrl, objKeySort, Md5 } from "@/utils/public";
import { recursion, category, parseTime } from "@/utils/index";
import { field_save } from "@/api/currency";

export default {
  data() {
    return {
      // 时间
      parseTime,
      // 分页
      current: {
        page: 1,
        per_page: 20,
      },
      limit: 20,
      totalCount: 1,
      // 当前行样式
      rowindex: "",
      // 点击的当前行
      selectRowIndex: "",
      // 搜索
      form: {
        send_time: parseTime(new Date(), "{y}-{m}-{d}"), //配送日期
        company_name: "", //商户名称
        send_time_id: 0, //配送时间
        sorting: 0, //分拣状态
      },
      type: false,
      // 总分拣单元 统计
      sort_arr_list: {
        count: 0,
        down_count: 0,
        in_count: 0,
        up_count: 0,
      },
      // 累加操作的信息
      addInfo: {
        id: "",
        num: "", //原始数据
        numhistory: [], //添加的记录
        new_num: 0, //添加数据
      },
      // 是否分次打印
      isPrint: true,
      // 累加弹出窗
      addDialogFormVisible: false,
      // 列表数据
      list: {
        arr: {},
        list: [],
      },
      listLoading: false,
      // 表头设置
      dialogFormVisible: false,
      type: [],
      // 表头设置列表
      field: {},
      Header: [
        {
          id: 1,
          name: "商品名称",
          disabled: true,
        },
        {
          id: 2,
          name: "下单数量",
          disabled: false,
        },
        {
          id: 3,
          name: "分拣数量",
          disabled: true,
        },
        {
          id: 4,
          name: "分拣单位",
          disabled: false,
        },
        {
          id: 5,
          name: "生产日期",
          disabled: true,
        },
        {
          id: 6,
          name: "库存",
          disabled: false,
        },
        {
          id: 7,
          name: "库存均价",
          disabled: false,
        },
        {
          id: 8,
          name: "分拣状态",
          disabled: false,
        },
        {
          id: 9,
          name: "备注",
          disabled: false,
        },
        {
          id: 10,
          name: "分拣员",
          disabled: false,
        },
        {
          id: 11,
          name: "分拣时间",
          disabled: false,
        },
      ],
      // 分类
      options: [],
      defaultProps: {
        children: "selfNext",
        label: "title",
        value: "id",
        checkStrictly: true,
      },
      // 选中
      checkList: [],
    };
  },
  computed: {
    // 已分拣完成订单
    over_count() {
      return (
        this.sort_arr_list.count -
        this.sort_arr_list.up_count -
        this.sort_arr_list.in_count
      );
    },
    // 分拣经度进度
    fenjian_percent() {
      let percent = 0;
      if (this.sort_arr_list.count == 0) {
        percent = 0;
      } else {
        percent = (this.over_count / this.sort_arr_list.count) * 100;
      }
      percent = Math.round(percent);
      return percent;
    },
  },
  created() {
    // 列表
    this.sorting_text();
  },
  // 刷新
  inject: ["reload"],
  methods: {
    // 打印
    qrAccount() {
      this.Preview(
        "1",
        "打印",
        "打印",
        "打印",
        "打印",
        "打印",
        "打印",
        "打印",
        "打印",
        [],
        "打印"
      );
    },
    Preview(
      code,
      nickname,
      line,
      title,
      attr_name,
      num,
      weight,
      shopping_time,
      id,
      bodyw,
      qrcode
    ) {
      if (getLodop()) {
        LODOP = getLodop();
        LODOP.SET_LICENSES(
          "",
          "B554E655041C03A234A3526A51F082F1",
          "C94CEE276DB2187AE6B65D56B3FC2848",
          ""
        );
        LODOP.PRINT_INITA(0, 0, 600, 400, "分拣打印");
        LODOP.SET_PRINT_PAGESIZE(1, 600, 400, "");
        this.AddPrintContent(
          code,
          nickname,
          line,
          title,
          attr_name,
          num,
          weight,
          shopping_time,
          id,
          bodyw,
          qrcode
        );
        // LODOP.PRINT();
        LODOP.PREVIEW();
      }
    },
    AddPrintContent(
      code,
      nickname,
      line,
      title,
      attr_name,
      num,
      weight,
      shopping_time,
      id,
      bodyw,
      qrcode
    ) {
      var c_height = 20,
        d_height = 18;
      LODOP.SET_PRINT_STYLE("FONTSIZE", 14);
      LODOP.SET_PRINT_STYLE("Bold", 1);
      LODOP.ADD_PRINT_TEXT(5, 10, 600, 400, code);

      LODOP.SET_PRINT_STYLE("FONTSIZE", 10);
      LODOP.SET_PRINT_STYLE("Bold", 0);
      LODOP.ADD_PRINT_TEXT(10, "57%", 600, 400, shopping_time);

      LODOP.SET_PRINT_STYLE("FONTSIZE", 10);
      LODOP.SET_PRINT_STYLE("Bold", 0);
      LODOP.ADD_PRINT_TEXT(32, 21, 600, 400, "名称:");

      LODOP.SET_PRINT_STYLE("FONTSIZE", 12);
      LODOP.SET_PRINT_STYLE("Bold", 1);
      LODOP.ADD_PRINT_TEXT(29, 55, 600, 400, title);

      LODOP.SET_PRINT_STYLE("FONTSIZE", 10);
      LODOP.SET_PRINT_STYLE("Bold", 0);
      LODOP.ADD_PRINT_TEXT(50, 21, 600, 400, "规格:" + attr_name);

      LODOP.SET_PRINT_STYLE("FONTSIZE", 10);
      LODOP.SET_PRINT_STYLE("Bold", 0);
      LODOP.ADD_PRINT_TEXT(67, 7, 600, 400, "预定量:" + num);

      LODOP.SET_PRINT_STYLE("FONTSIZE", 10);
      LODOP.SET_PRINT_STYLE("Bold", 0);
      LODOP.ADD_PRINT_TEXT(67, "50%", 600, 400, "配送量:");
      LODOP.ADD_PRINT_LINE(85, 0, 85, 600, 0, 1);

      LODOP.SET_PRINT_STYLE("FONTSIZE", 14);
      LODOP.SET_PRINT_STYLE("Bold", 1);
      LODOP.ADD_PRINT_TEXT(62, "71%", 600, 400, weight);
      LODOP.ADD_PRINT_LINE(85, 0, 85, 600, 0, 1);
      if (bodyw.length != 0) {
        for (var i = 0; i < bodyw.length; i++) {
          if (i == 0) {
            LODOP.SET_PRINT_STYLE("FONTSIZE", 10);
            LODOP.SET_PRINT_STYLE("Bold", 1);
            c_height = c_height + 74;
            LODOP.ADD_PRINT_TEXT(
              c_height,
              7,
              150,
              400,
              bodyw[i].key + ":" + bodyw[i].val
            );
          } else {
            LODOP.SET_PRINT_STYLE("FONTSIZE", 10);
            LODOP.SET_PRINT_STYLE("Bold", 1);
            c_height = c_height + d_height;
            LODOP.ADD_PRINT_TEXT(
              c_height + 20,
              7,
              600,
              400,
              bodyw[i].key + ":" + bodyw[i].val
            );
          }
        }
      }

      if (qrcode == 1) {
        LODOP.ADD_PRINT_IMAGE(
          85,
          "66%",
          600,
          400,
          '<img src="http://test.caidj.cn/qrCode?text=http://test.caidj.cn/%23/fenjian?id=' +
            id +
            '">'
        );
      }
    },
    // 累加
    accumu() {},
    // 搜索勾选
    checkbox() {
      console.log(this.label);
    },
    // 分类
    handleChange(value) {
      console.log(value);
    },
    demo() {
      console.log("demo");
    },
    // 单元格的style 的回调方法
    cellStyle({ row, rowIndex }) {
      console.log(row);
      if (rowIndex === this.rowindex[1]) {
        return "success";
      } else {
        return;
      }
    },
    //input 框聚焦时
    inputFocus(index, scope, $event) {
      this.selectRowIndex = index[0];
      this.rowindex = index;
      scope.row.sort_num = "";
    },
    // 焦点离开商品分类
    nextFocus(props, scope, $event) {
      let id = scope.row.id;
      let index = scope.$index;
      let val = $event.target.value;
      let rowFatherIndex = props.$index;
      let rowSonIndex = scope.$index + 1;
      if (/^(\d+\.?)?\d{0,2}$/.test(parseFloat(val)) && val != "") {
        $event.target.blur();
        let parmas = {
          id: id,
          num: val,
        };
        scope.row.disabled = true;
        this.xiugai(parmas);

        // this.$nextTick((x) => {
        //   this.$refs["sorting" + rowFatherIndex + rowSonIndex][0].focus();
        // });
      } else {
        this.$message.warning("请输入正确的数字订单");
        $event.target.value = "";
      }
    },
    // 焦点离开分拣数量--松哥
    inputBlur(val, index, ind) {
      if (
        /^(\d+\.?)?\d{0,2}$/.test(parseFloat(val.target.value)) &&
        val.target.value != ""
      ) {
        this.list[index].child[ind].disabled = true;
        // console.log(this.list[index].child[ind].num);
        this.offset(index, ind);
      } else {
        this.$nextTick(() => {
          if (val.target.offsetParent) {
            val.target.offsetParent.querySelector("input").focus();
          }
        });
      }
    },
    offset(index, ind) {
      if (index < this.list.length) {
        if (ind < this.list[index].child.length) {
          if (this.list[index].child[ind].disabled) {
            this.offset(index, (ind += 1));
          } else {
            this.$refs[
              "sorting" + String(index) + String(ind)
            ][1].$el.offsetParent
              .querySelector("input")
              .focus();
          }
        } else {
          if (this.list[index + 1]) {
            if (this.list[index + 1].child[0].disabled) {
              this.offset(index + 1, 1);
            } else {
              this.$refs[
                "sorting" + String(index + 1) + String(0)
              ][1].$el.offsetParent
                .querySelector("input")
                .focus();
            }
          }
        }
      }
    },
    // 订购数量？注释
    renderHeader(h, { column, $index }) {
      // 这里在最外层插入一个div标签
      return h("div", [
        // h即为cerateElement的简写
        // 在div里面插入span
        h("span", {
          // 表示内容
          domProps: {
            innerHTML: column.label,
          },
          on: {
            click: () => {
              console.log(`${column.label}   ${$index}`);
            },
          },
        }),
        h(
          "el-tooltip",
          {
            // 表示属性
            attrs: {
              effect: "dark",
              content: "所有档口下单数量的总和！",
              placement: "top",
            },
          },
          [
            h("i", {
              style: "margin-left: 5px;margin-top:-1px;",
              class: "el-icon-question table-msg",
            }),
          ]
        ),
      ]);
    },
    // 搜索
    getArticleList() {
      this.rowindex = "";
      this.current.page = 1;
      this.sorting_text();
    },
    // 分页
    changeLimit(pageSize) {
      this.current.per_page = pageSize;
      this.sorting_text();
    },
    changePage(page) {
      this.current.page = page;
      this.sorting_text();
    },
    // 设置确认
    setupmine(val) {
      let arry = [];
      this.Header.map((e) => {
        this.type.map((p) => {
          if (e.id == p) {
            arry.push(e.id);
            return;
          }
        });
      });
      let data = Object.assign(
        {
          sign: Md5(
            objKeySort(Object.assign(apiUrl().name, { type: 9 })) +
              apiUrl().appsecret
          ),
        },
        apiUrl().name,
        { type: 9, fields: JSON.stringify(arry) }
        // [1,2,3,4,5,6,7,8,9,10]
      );
      field_save(data).then((res) => {
        if (res.errcode == 0) {
          this.$message({
            message: "设置成功",
            type: "success",
          });
          this.reload();
        } else {
          this.$message.error(res.errmsg);
        }
      });
    },
    // 列表
    sorting_text() {
      this.listLoading = true;
      let data = Object.assign(
        {
          sign: Md5(
            objKeySort(Object.assign(apiUrl().name, this.form, this.current)) +
              apiUrl().appsecret
          ),
        },
        this.form,
        apiUrl().name,
        this.current
      );
      sorting_text(data).then((res) => {
        console.log(res);
        this.listLoading = false;
        if (res.errcode == 0) {
          // this.options = recursion(res.data.arr.categoryList, true);
          // res.data.arr.list.data.map((e) => {
          //   e.disabled = false;
          // });
          // this.type = res.data.arr.field;
          this.sort_arr_list = res.data.arr.user_sort_arr_list;
          res.data.arr.list.map((e) => {
            e.list.map((e) => {
              e.disabled = e.status == 0 ? false : true;
            });
          });
          this.list = res.data.arr;
          this.field = res.data.arr.field;
          this.type = res.data.arr.field;
          console.log(this.list);
        } else {
          this.$message.error(res.errmsg);
        }
      });
    },
    // 商品累计添加
    sorting_accumulation() {
      let data = Object.assign(
        {
          sign: Md5(
            objKeySort(Object.assign(apiUrl().name) + apiUrl().appsecret)
          ),
        },
        { id: this.addInfo.id, num: 12 }
      );
      sorting_accumulation(data).then((res) => {
        if (res.errcode !== 0) {
          this.$message.error("添加失败，请重试");
        }
      });
    },
    // 分拣缺货
    quehuo(id) {
      let data = Object.assign(
        {
          sign: Md5(
            objKeySort(Object.assign(apiUrl().name) + apiUrl().appsecret)
          ),
        },
        { id: id }
      );
      sorting_stock(data).then((res) => {
        if (res.errcode == 0) {
          this.$message.success("提交成功");
        } else {
          this.$message.error(res.errmsg);
        }
      });
    },
    // 分拣撤销
    chexiao(id) {
      let data = Object.assign(
        {
          sign: Md5(
            objKeySort(Object.assign(apiUrl().name) + apiUrl().appsecret)
          ),
        },
        { id: id }
      );
      sorting_revoke(data).then((res) => {
        console.log(res);
        if (res.errcode == 0) {
          this.$message.success("商品撤销成功");
        } else {
          this.$message.error(res.errmsg);
        }
      });
    },

    // 累加框展示
    accumu(value) {
      let res = value.row;
      this.addInfo.id = res.id;
      this.addInfo.num = res.sort_num;
      this.addDialogFormVisible = true;
    },
    // 累加回车事件
    countadd(value) {
      this.addInfo.num =
        parseFloat(this.addInfo.num) + parseFloat(this.addInfo.new_num);
      this.addInfo.numhistory.push(this.addInfo.new_num);
      this.sorting_accumulation();
      this.addInfo.new_num = "";
    },
    // 累加完成事件
    accountComplete() {
      this.addDialogFormVisible = false;
      this.addInfo.numhistory = [];
      this.sorting_text();
    },
    // 分拣修改请求
    xiugai(parmas) {
      let data = Object.assign(
        {
          sign: Md5(
            objKeySort(Object.assign(apiUrl().name) + apiUrl().appsecret)
          ),
        },
        parmas
      );
      sorting_add(data).then((res) => {
        if (res.errcode == 0) {
          this.$message.success("分拣数量添加成功");
        } else {
          this.$message.error("分拣数量添加失败");
        }
      });
    },
    // 分拣数量修改
    fenjiancount(val, scope) {
      let id = scope.row.id;
      let parmas = {
        id: id,
        num: val,
      };
      this.xiugai(parmas);
    },
    // 生产日期修改
    fenjiantime(val, scope) {
      let id = scope.row.id;
      let params = {
        id: id,
        mfg: val,
      };
      this.xiugai(params);
    },
    // 分拣修改事件
    xiugaiMethod(scope) {
      scope.row.disabled = !scope.row.disabled;
    },

    //分拣全部
    sortingAll() {
      let goodsList = this.list.list.data;
      let newList = [];
      goodsList.forEach((item) => {
        newList.push(item.id);
      });
      console.log(newList);
    },
  },
};
</script>
<style lang="scss" scoped>
@import "@/styles/variables.scss";

.mainor_form form {
  width: calc(100% - 430px);
  .mainsw_fo {
    margin-bottom: 3px;
    display: flex;
    /deep/.el-select {
      margin-bottom: 15px;
    }
    /deep/.el-cascader {
      margin-bottom: 15px;
    }
  }
}
/deep/.main_table .el-table--small .cell {
  height: 28px !important;
}
.mainsa_te {
  svg {
    vertical-align: -2px;
  }
  use {
    fill: #c1c1c1;
  }
}
.mainsw_ta {
  /deep/.el-checkbox-group {
    font-size: initial;
  }
  .mainsw_tax {
    margin-top: 20px;
    &:first-child {
      margin-top: 0;
    }
    .mainsw_tax_t {
      margin-bottom: 2px;
      overflow-x: auto;
      /deep/.el-button {
        position: absolute;
        right: 35px;
        margin-top: 8px;
      }
      table {
        width: 100%;
        border-collapse: collapse;
        table-layout: fixed;
        word-break: break-all;
        border-spacing: 0;
        thead {
          height: 51px;
          line-height: 51px;
          background: $colour_f7;
          th {
            font-size: $font_14;
            color: $colour_3;
            text-align: left;
            padding-left: 10px;
            padding-right: 10px;
          }
        }
        .mainsw_tax_tb {
          height: 2px;
        }
        tbody {
          tr {
            background: $colour_f7;
            td {
              word-break: break-all;
              height: 51px;
              line-height: 51px;
              font-size: $font_14;
              color: $colour_3;
              padding-left: 10px;
              padding-right: 10px;
              .mainsw_tax_th {
                height: 20px;
                line-height: 20px;
              }
              .mainsw_tax_ts {
                margin-left: 20px;
              }
            }
          }
        }
      }
      /deep/.el-checkbox__label {
        display: none;
      }
    }
  }
}

/deep/.el-table tr.expanded + tr .mainex_ta {
  background: #fafafa !important;
}
/deep/.el-table tr.expanded + tr .mainex_ta th,
/deep/.el-table tr.expanded + tr .mainex_ta tr {
  background: #fafafa !important;
}

// 当表格行选择的时候
/deep/.el-table .success {
  color: red;
  font-weight: 700;
  font-size: 20px;
}
</style>
